//
//  ProgressViewViewController.m
//  ProgressView
//

#import "ProgressViewViewController.h"

NSTimer *timer;

@implementation ProgressViewViewController

- (void)updateProgress:(NSTimer *)sender {
	UIProgressView *progress = [sender userInfo];
	
	// 작업이 끝났는가?
	if (progress.progress == 1.0) {
		[timer invalidate];
	} else {
		progress.progress += 0.05;
	}

}

- (void)viewDidLoad {
    [super viewDidLoad];
	
	UIProgressView *myProgressView = [[UIProgressView alloc]
		initWithProgressViewStyle:UIProgressViewStyleDefault];
	
	CGRect progressFrame = CGRectMake(10, 100, 300, 25);
	[myProgressView setFrame:progressFrame];
	
	[myProgressView setProgress:0.0];
	
	[self.view addSubview:myProgressView];
	
	[myProgressView release];
	
	// 타이머 설정
	timer = [[NSTimer
			  scheduledTimerWithTimeInterval:0.1
			  target:self
			  selector:@selector(updateProgress:)
			  userInfo:myProgressView
			  repeats:YES] retain];
}

- (void)dealloc {
    [super dealloc];
}

@end
